package com.distribution.system.service.impl;

import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.distribution.common.exception.ServiceException;
import com.distribution.system.domain.entity.CmccDaProductClassify;
import com.distribution.system.mapper.CmccDaProductClassifyMapper;
import com.distribution.system.service.CmccDaProductClassifyService;
import org.springframework.stereotype.Service;

import java.util.List;
import java.util.stream.Collectors;

/**
 * @author: GodLu
 * @create: 2024-07-17 08:59
 * @description: TODO
 */
@Service
public class CmccDaProductClassifyServiceImpl extends ServiceImpl<CmccDaProductClassifyMapper, CmccDaProductClassify> implements CmccDaProductClassifyService {
    @Override
    public List<String> getClassifyNameList() {
        List<CmccDaProductClassify> list = list(new LambdaQueryWrapper<CmccDaProductClassify>().eq(CmccDaProductClassify::getStatus,"1"));
        if (list == null || list.isEmpty()) throw new ServiceException("查不到产品分类");
        return list.stream().map(CmccDaProductClassify::getClassifyName).collect(Collectors.toList());
    }
}
